/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package org.vinavac.entity;

import java.io.Serializable;
import java.util.Date;
import java.util.List;
import javax.persistence.*;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author Quang <quangtin3@gmail.com>
 */
@Entity
@Table(name = "weekly_calendar")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "WeeklyCalendar.findAll", query = "SELECT w FROM WeeklyCalendar w"),
    @NamedQuery(name = "WeeklyCalendar.findById", query = "SELECT w FROM WeeklyCalendar w WHERE w.id = :id"),
    @NamedQuery(name = "WeeklyCalendar.findByEventDate", query = "SELECT w FROM WeeklyCalendar w WHERE w.eventDate = :eventDate"),
    @NamedQuery(name = "WeeklyCalendar.findByEventTime", query = "SELECT w FROM WeeklyCalendar w WHERE w.eventTime = :eventTime"),
    @NamedQuery(name = "WeeklyCalendar.findByEventType", query = "SELECT w FROM WeeklyCalendar w WHERE w.eventType = :eventType"),
    @NamedQuery(name = "WeeklyCalendar.findByOtherPreparation", query = "SELECT w FROM WeeklyCalendar w WHERE w.otherPreparation = :otherPreparation")})
public class WeeklyCalendar implements Serializable {

    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "ID")
    private Integer id;
    @Basic(optional = false)
    @NotNull
    @Column(name = "EVENT_DATE")
    @Temporal(TemporalType.DATE)
    private Date eventDate;
    @Size(max = 64)
    @Column(name = "EVENT_TIME")
    private String eventTime;
    @Size(max = 64)
    @Column(name = "EVENT_TYPE")
    private String eventType;
    @Size(max = 256)
    @Column(name = "OTHER_PREPARATION")
    private String otherPreparation;
    @JoinTable(name = "weekly_calendar_has_staff", joinColumns = {
        @JoinColumn(name = "weekly_calendar_ID", referencedColumnName = "ID")}, inverseJoinColumns = {
        @JoinColumn(name = "staff_ID", referencedColumnName = "ID")})
    @ManyToMany
    private List<Staff> staffList;
    @JoinTable(name = "weekly_calendar_has_commune", joinColumns = {
        @JoinColumn(name = "weekly_calendar_ID", referencedColumnName = "ID")}, inverseJoinColumns = {
        @JoinColumn(name = "commune_ID", referencedColumnName = "ID")})
    @ManyToMany
    private List<Commune> communeList;

    public WeeklyCalendar() {
    }

    public WeeklyCalendar(Integer id) {
        this.id = id;
    }

    public WeeklyCalendar(Integer id, Date eventDate) {
        this.id = id;
        this.eventDate = eventDate;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public Date getEventDate() {
        return eventDate;
    }

    public void setEventDate(Date eventDate) {
        this.eventDate = eventDate;
    }

    public String getEventTime() {
        return eventTime;
    }

    public void setEventTime(String eventTime) {
        this.eventTime = eventTime;
    }

    public String getEventType() {
        return eventType;
    }

    public void setEventType(String eventType) {
        this.eventType = eventType;
    }

    public String getOtherPreparation() {
        return otherPreparation;
    }

    public void setOtherPreparation(String otherPreparation) {
        this.otherPreparation = otherPreparation;
    }

    @XmlTransient
    public List<Staff> getStaffList() {
        return staffList;
    }

    public void setStaffList(List<Staff> staffList) {
        this.staffList = staffList;
    }

    @XmlTransient
    public List<Commune> getCommuneList() {
        return communeList;
    }

    public void setCommuneList(List<Commune> communeList) {
        this.communeList = communeList;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof WeeklyCalendar)) {
            return false;
        }
        WeeklyCalendar other = (WeeklyCalendar) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "org.vinavac.entity.WeeklyCalendar[ id=" + id + " ]";
    }
}
